package com.zyong.design.pattern.iterator.case2;

import java.util.Iterator;

/**
 * @program: zyong-design-pattern
 * @ClassName: Client
 * @author: zyong
 * @create: 2024-06-01 08:55
 */
public class Client {
    public static void main(String[] args) {
        ProductCatalog products = new ProductCatalog();

        products.addProduct(new Product("P1", 20));
        products.addProduct(new Product("P2", 30));
        products.addProduct(new Product("P3", 40));
        products.addProduct(new Product("P4", 50));

        for (Product product : products) {
            System.out.println(product);
        }

        System.out.println("================================================");

        Iterator<Product> iterator = products.iterator();
        while (iterator.hasNext()) {
            Product product = iterator.next();
            System.out.println(product.toString());
        }
    }
}
